package com.threegroup.android3grouppersonality.ui.activity;

import android.graphics.Paint;
import android.os.Bundle;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.threegroup.android3grouppersonality.R;
import com.threegroup.android3grouppersonality.ui.fragment.fragmentDetails.FavoritesFragment;
import com.threegroup.android3grouppersonality.ui.fragment.fragmentDetails.IndexDetailsFragment;
import com.threegroup.android3grouppersonality.ui.fragment.fragmentDetails.PhotoFragment;

public class PersoninfoActivity extends AppCompatActivity implements View.OnClickListener {
    private ImageView Userdetailimg;
    private FavoritesFragment favoritesFragment;
    private IndexDetailsFragment indexDetailsFragment;
    private TextView tv_favorites,tv_index,tv_poto;
    private PhotoFragment photoFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_personinfo);
        initial();
    }

    private void initial() {
        Userdetailimg = findViewById(R.id.iv_userdetail);
        Userdetailimg.setImageResource(R.drawable.loginimg);
        //加载圆形头像，通过util中的CircleImageView转换成圆形，传入必须为图片比特流
        tv_favorites = findViewById(R.id.tv_favorites);
        tv_favorites.setOnClickListener(this);
        tv_index = findViewById(R.id.tv_index);
        tv_index.setOnClickListener(this);
        tv_poto = findViewById(R.id.tv_poto);
        tv_poto.setOnClickListener(this);
        indexDetailsFragment = new IndexDetailsFragment();
        favoritesFragment = new FavoritesFragment();
        photoFragment=new PhotoFragment();
        getSupportFragmentManager().beginTransaction().replace(R.id.fl_persondetail, indexDetailsFragment).commit();

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_index:
                getSupportFragmentManager().beginTransaction().replace(R.id.fl_persondetail, indexDetailsFragment).commit();
                break;

            case R.id.tv_favorites:
                getSupportFragmentManager().beginTransaction().replace(R.id.fl_persondetail, favoritesFragment).commit();
                break;
            case R.id.tv_poto:
                getSupportFragmentManager().beginTransaction().replace(R.id.fl_persondetail, photoFragment).commit();
                break;
        }

    }
}